import React, { Component, Fragment } from 'react'
import store from '../../store'

class CountRedux extends Component {
    render () {
        return (
            <Fragment>
                <button onClick={this.reduce}>-</button>
                <span>{store.getState().count.count}</span>
                <button onClick={this.add}>+</button>
            </Fragment>
        )
    }

    add () {
        store.dispatch({ type: 'ADD_COUNT', count: 1 })
        console.log('add')
    }

    reduce () {
        store.dispatch({ type: 'REDUCE_COUNT', count: 1 })
        console.log('reduce')
    }
}

export default CountRedux
